package com.example.myapplication;

import com.example.myapplication.shortvideo.utils.GsonUtil;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: rongfeng
 * @date: 2020/12/15
 * @description
 */
public class DowdLoadImg4 {

    public static void main(String[] args) {
        new Query().getDns();
    }


    public static class Query {
        List<DowdLoadImg2.DataList> urlList = new ArrayList<>();

        public void getDns() {
            File file = new File("C:\\Users\\demo\\Desktop\\json.txt");
            try {
                String str;
                FileInputStream fileInputStream = new FileInputStream(file);
                InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
                BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

                StringBuffer sb = new StringBuffer();
                String text = null;
                while ((text = bufferedReader.readLine()) != null) {
                    sb.append(text);
                }
                str = sb.toString();

                JsonsRootBean.Root bean = GsonUtil.parse(str, JsonsRootBean.Root.class);
                for ( List<JsonsRootBean.Data>    item : bean.getList()) {
                    for (JsonsRootBean.Data item2: item  ) {
                        urlList.add(new DowdLoadImg2.DataList(item2.ico));
                    }
                }

//                System.out.println(urlList);
                new DowdLoadImg2().addList(urlList);
            } catch (Exception e) {
                e.printStackTrace();
            }

        }


        /**
         * Auto-generated: 2020-12-16 15:7:34
         *
         * @author www.jsons.cn
         * @website http://www.jsons.cn/json2java/
         */
        public static class JsonsRootBean {
            public static class Data
            {
                private int id;

                private String name;

                private String ico;

                private String intro;

                public void setId(int id){
                    this.id = id;
                }
                public int getId(){
                    return this.id;
                }
                public void setName(String name){
                    this.name = name;
                }
                public String getName(){
                    return this.name;
                }
                public void setIco(String ico){
                    this.ico = ico;
                }
                public String getIco(){
                    return this.ico;
                }
                public void setIntro(String intro){
                    this.intro = intro;
                }
                public String getIntro(){
                    return this.intro;
                }
            }


            public static class Root
            {
                private List<List<Data>> list;

                public void setList(List<List<Data>> list){
                    this.list = list;
                }
                public List<List<Data>> getList(){
                    return this.list;
                }
            }

        }
    }
}
